package cn.wikiflyer.beikang.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import cn.wikiflyer.beikang.R;

/**
 * @author maizi
 *
 */
public class BannerPro extends LinearLayout {
	private TextView tv1;
	private TextView tv2;
	public BannerPro(Context context) {
		super(context);
	}

	public BannerPro(Context context, AttributeSet attrs) {
		super(context, attrs);
		addView(View.inflate(context, R.layout.bk_banner_pro_lay, null));
		initView();
		loadParams(attrs);
	}
	private void initView(){
		tv1 = (TextView) findViewById(R.id.textView1);
		tv2 = (TextView) findViewById(R.id.textView2);
	}
	
	private void loadParams(AttributeSet attrs) {
		TypedArray ta = this.getContext().obtainStyledAttributes(attrs,
				R.styleable.BannerPro);
		String leftStr = ta.getString(R.styleable.BannerPro_leftText);
		if (leftStr != null) {
			tv1.setText(leftStr);
		}
		String rightStr = ta.getString(R.styleable.BannerPro_rightText);
		if (rightStr != null) {
			tv2.setText(rightStr);
		}
		Boolean isShow = ta.getBoolean(R.styleable.BannerPro_isShow, false);
		if (isShow) {
			tv2.setVisibility(View.VISIBLE);
		}else{
			tv2.setVisibility(View.INVISIBLE);
		}
		ta.recycle();
	}
	
	/**
	 * 设置第二个标签的监听
	 */
	public void setOnClickListener(OnClickListener listener){
		tv2.setOnClickListener(listener);
	}
	
	
	
}
